package Coding.IO;

import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.nio.charset.StandardCharsets;

public class WriteStringToFile {


    public static void main(String[] args) throws IOException {

        File file = new File("writeStringToFile.txt");
        FileOutputStream fileOutputStream = new FileOutputStream("./writeStringToFile.txt");


        String line = "Love Java";
        fileOutputStream.write(line.getBytes());
        fileOutputStream.write(line.getBytes(StandardCharsets.UTF_8)); //如果有中文字符串，避免乱码


        
        fileOutputStream.close();

    }
}
